import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import vue from '@vitejs/plugin-vue'


export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  
  }, 
  define: {
      'process.env': {}
    },
  /* 代理 */
  server: {
    proxy:{
      '/api':{
        /* 要代理的源 */
        target:'http://localhost:8080',
        /* 是否开启代理 */
        changeOrigin:true,
        /* 重写代理后的源 */
        rewrite:(path)=>path.replace(/^\/api/,'')
      }
    }
  }
})




